<template>
  <div>
    <el-breadcrumb separator-class="el-icon-arrow-right" style="font-size: 16px;">
      <el-breadcrumb-item :to="{ path: '/sys-admin' }">
        <i class="el-icon-s-promotion"></i> 后台管理
      </el-breadcrumb-item>
      <el-breadcrumb-item>订单列表</el-breadcrumb-item>
    </el-breadcrumb>

    <el-divider></el-divider>

    <el-table :data="tableData" border style="width: 100%">
      <el-table-column prop="id" label="id" width="60" align="center"></el-table-column>
      <el-table-column prop="detailId" label="手机详情id" width="120" align="center"></el-table-column>
      <el-table-column label="手机图片" width="280">
        <template slot-scope="scope">
          <!--scope里面装着这一行所对应的对象信息,scope.$index得到下标
          scope.row得到这一行对应数组里面的图片路径-->
          <img :src="require('D:/files/'+scope.row.url)" width="100%" alt="">
        </template>
      </el-table-column>
      <el-table-column prop="phoneId" label="手机id" align="center"></el-table-column>
      <el-table-column prop="phoneNumber" label="手机号" align="center"></el-table-column>
      <el-table-column prop="purchaseVolume" label="购买量" align="center"></el-table-column>
      <el-table-column prop="address" label="收货地址" align="center"></el-table-column>
      <el-table-column prop="remark" label="备注" align="center"></el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  data() {
    return {
      tableData: []
    }
  },
  methods: {
    loadOrderList() {
      console.log('准备从服务器端加载【订单列表】……');
      let url = 'http://localhost:9081/orders';
      console.log('请求路径：' + url);
      this.axios
          .create({'headers': {'Authorization': localStorage.getItem('jwt')}})
          .get(url)
          .then((response) => {
            let responseBody = response.data;
            console.log('接收到服务器端响应的结果：');
            console.log(responseBody);
            this.tableData = responseBody.data;
            console.log(tableData)
          });
    }
  },
  mounted() {
    console.log('mounted');
    this.loadOrderList();
  }
}
</script>

<style scoped>

</style>